//
//  RightViewController.m
//  Leisure
//
//  Created by xalo on 16/6/28.
//  Copyright © 2016年 朱旭东. All rights reserved.
//

/// logical: 添加Item点击切换到menuVC的方法和手势方法
#import "RightViewController.h"

@interface RightViewController ()
@property(nonatomic,strong)UIPanGestureRecognizer *backPan;
@property(nonatomic,strong)UIScreenEdgePanGestureRecognizer *screenEdgePan;
@property(nonatomic,strong)UISwipeGestureRecognizer *swip;
@end

@implementation RightViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    //创建Barbutton
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(itemAction)];
    
    self.swip = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(viewSlide:)];
    [self.view  addGestureRecognizer:self.swip];
}


//item点击方法
-(void)itemAction{
    
    if (!self.isSloder) {
        //向右偏移
        [UIView  animateWithDuration:0.2 animations:^{
            self.navigationController.view.frame = CGRectMake(kwidth/2, 0, kwidth, kheight);
        self.swip.direction= UISwipeGestureRecognizerDirectionLeft;
        }];
    }else{
        [UIView  animateWithDuration:0.2 animations:^{
            //回到原位
            self.navigationController.view.frame = CGRectMake(0, 0, kwidth, kheight);
            self.swip.direction= UISwipeGestureRecognizerDirectionRight;
        }];
    }
    
    self.isSloder = !self.isSloder;
    
}

//滑动方法
- (void)viewSlide:(UISwipeGestureRecognizer *)sender{

    if (sender.direction == UISwipeGestureRecognizerDirectionRight) {
        self.navigationController.view.frame = CGRectMake(kwidth/2, 0, kwidth, kheight);
        self.isSloder = NO;
        self.swip.direction= UISwipeGestureRecognizerDirectionLeft;
    }else{
        self.navigationController.view.frame = CGRectMake(0, 0, kwidth, kheight);
        self.swip.direction= UISwipeGestureRecognizerDirectionRight;

    }
        self.isSloder = !self.isSloder;
}
@end
